package com.elcom.roaming.module.synthesis.isup;

import com.elcom.roaming.common.util.match.Matching;
import com.elcom.roaming.common.util.match.ObjectInput;
import com.elcom.roaming.module.synthesis.match.MSRNMatchingObjects;
import com.elcom.roaming.module.synthesis.match.MSRNMessage;

public class ISUPMatching extends Matching{

	private MSRNMatchingObjects msrnMatching;

	public ISUPMatching(MSRNMatchingObjects msrnMatching) {
		this.msrnMatching = msrnMatching;
	}

	@Override
	public void forward(ObjectInput obj) {
		ISUPKey key = (ISUPKey) obj.getKey();
		ISUPValue value = (ISUPValue) obj.getValue();
		ISUPValue dropValue = (ISUPValue) obj.getDropValue();
		
		if (value.getType() == dropValue.getType()) return ;
		
		MSRNMessage msrnMsg = new MSRNMessage(key.seq, "IAM", key.getPutTime(), dropValue.calledMSRN, dropValue.calling, null, null);
		logger.info("Matching ISUP on MSRN Map:" + obj.toString());
		msrnMatching.match(msrnMsg);
	}

}
